import request from '../utils/request'

/**
 * 登录
 *
 * @param {*} params
 * @returns
 */
export const login = params => {
  return request({
    url: '/login',
    method: 'post',
    data: params
  })
}

/**
 * 获取用户列表数据
 *
 * @param {*} params
 * @returns
 */
export const getUserList = params => {
  return request({
    url: '/users?pagenum=' + params.pagenum + '&pagesize=' + params.pagesize + '&query=' + params.query,
    method: 'get'
  })
}

/**
 * 添加新用户
 *
 * @param {*} params
 * @returns
 */
export const postAddUsers = params => {
  return request({
    url: '/users',
    method: 'post',
    data: params
  })
}

/**
 * 根据 ID 查询用户信息
 *
 * @param {*} params
 * @returns
 */
export const getUserInfoById = params => {
  return request({
    url: `/users/${params}`,
    method: 'get'
  })
}

/**
 * 编辑用户信息提交
 *
 * @param {*} params
 * @returns
 */
export const putEditUserInfo = params => {
  return request({
    url: `/users/${params.id}`,
    method: 'put',
    data: {
      email: params.email,
      mobile: params.mobile
    }
  })
}

/**
 * 改变用户状态
 *
 * @param {*} params
 * @returns
 */
export const putUserState = params => {
  return request({
    url: `/users/${params.id}/state/${params.mg_state}`,
    method: 'put'
  })
}

/**
 * 根据 ID 删除用户
 *
 * @param {*} params
 * @returns
 */
export const deleteUserById = params => {
  return request({
    url: `/users/${params}`,
    method: 'delete'
  })
}
